package main

import (
	"fmt"
	"github.com/rsc/pdf"
	"io/ioutil"
	"os"
	"strconv"
)

func main() {
	fi, err := os.Open("bookpath.txt")
	if err != nil {
		return
	}

	defer fi.Close()
	fd, err := ioutil.ReadAll(fi)
	if err != nil {
		return
	}

	file,err := pdf.Open(string(fd))
	if(err != nil){
		panic(err)
	}

	fin, err := os.Create("pdfnum.txt")
	if err != nil {
		return
	}
	defer fin.Close()
	numStr := strconv.Itoa(file.NumPage())
	fmt.Println(numStr)
	fin.WriteString(numStr)
}
